package com.moore.utils;

import java.util.concurrent.*;

public class ThreadPoolUtils {
    private final ExecutorService executorService;
    private static final ThreadPoolUtils threadPoolUtils = new ThreadPoolUtils();
    private ThreadPoolUtils(){
        executorService = new ThreadPoolExecutor(
                10,
                20,
                2L,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(10),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
    }
    public void execute(Runnable runnable){
        executorService.execute(runnable);
    }
    public static ThreadPoolUtils getInstance(){
        return threadPoolUtils;
    }
}
